import $http from "./index"
import url from "./url"
import type { AxiosResponse } from "axios"
type CommonRes = Promise<AxiosResponse<Res>>;
//获取学生
// export function getStudents(query:StudentQuery):Promise<AxiosResponse<StudentData[]>>{
//     return $http.get(url.STUDENTS,query)
// }
export function login(body: LoginForm): Promise<AxiosResponse<LoginRes>> {
    return $http.post(url.LOGIN, body);
}
export function password(body: PassForm): CommonRes {
    return $http.put(url.PASSWORD, body);
}
//角色管理接口
export function getRole(query: CommonQuery): Promise<AxiosResponse<DataRes<RoleData[]>>> {
    return $http.get(url.ROLE, query);
}
export function addRole(body: RoleForm): CommonRes {
    return $http.post(url.ROLE, body)
}
export function findByRid(rid: number): CommonRes {
    return $http.get(url.FINDBYRID, { rid })
}
export function delRole(id: number): CommonRes {
    return $http.delete(url.ROLE + "/" + id)
}
export function edtRole(id:number,body:Partial<RoleForm>):CommonRes{
    return $http.put(url.ROLE + "/" + id,body)
}
export function getRoleById(id:number): Promise<AxiosResponse<DataRes<RoleData>>> {
    return $http.get(url.ROLE+"/"+id);
}
//成员管理接口
export function getManager(query: ManagerQuery): Promise<AxiosResponse<DataRes<ManagerData[]>>> {
    return $http.get(url.MANAGER, query);
}
export function addManager(body:ManagerForm):CommonRes{
    return $http.post(url.MANAGER,body)
}
export function delManager(id: number): CommonRes {
    return $http.delete(url.MANAGER + "/" + id)
}
export function oneManager(id:number):Promise<AxiosResponse<DataRes<ManagerInfo>>>{
    return $http.get(url.MANAGER+"/"+id);
}
export function edtManager(id:number,body:Partial<ManagerInfo>):CommonRes{
    return $http.put(url.MANAGER + "/" + id,body)
}
//客户管理接口
export function getCustomer(query: CustomerQuery): Promise<AxiosResponse<DataRes<CustomerData[]>>> {
    return $http.get(url.CUSTOMER, query);
}
export function addCustomer(body:Partial<CustomerData>):CommonRes{
    return $http.post(url.CUSTOMER,body);
}
export function delCustomer(id: number): CommonRes {
    return $http.delete(url.CUSTOMER + "/" + id)
}
export function oneCustomer(id:number):Promise<AxiosResponse<DataRes<CustomerData>>>{
    return $http.get(url.CUSTOMER+"/"+id);
}
export function edtCustomer(id:number,body:CustomerData):CommonRes{
    return $http.put(url.CUSTOMER + "/" + id,body)
}
//合同管理接口
export function getContract(query: ContractQuery): Promise<AxiosResponse<DataRes<ContractData[]>>> {
    return $http.get(url.CONTRACT, query);
}
export function addContract(body:Partial<ContractData>):CommonRes{
    return $http.post(url.CONTRACT,body);
}
export function delContract(id: number): CommonRes {
    return $http.delete(url.CONTRACT + "/" + id)
}
export function oneContract(id:number):Promise<AxiosResponse<DataRes<ContractData>>>{
    return $http.get(url.CONTRACT+"/"+id);
}
export function edtContract(id:number,body:ContractData):CommonRes{
    return $http.put(url.CONTRACT + "/" + id,body)
}
//菜单管理接口
export function getMenu(query: CommonQuery): Promise<AxiosResponse<DataRes<MenuData[]>>> {
    return $http.get(url.MENU, query);
}
export function addMenu(body:MenuForm):CommonRes{
    return $http.post(url.MENU,body);
}
export function delMenu(id: number): CommonRes {
    return $http.delete(url.MENU + "/" + id)
}
// export function oneMenu(id:number):Promise<AxiosResponse<DataRes<MenuData>>>{
//     return $http.get(url.MENU+"/"+id);
// }
export function edtMenu(id:number,body:MenuForm):CommonRes{
    return $http.put(url.MENU + "/" + id,body)
}